//
//  IPViewController.m
//  IOS_IP
//
//  Created by 李腾飞 on 15/4/8.
//  Copyright (c) 2015年 李腾飞. All rights reserved.
//

#import "IPViewController.h"
#import "B9ZGX_IPDetector.h"

@interface IPViewController ()

@end

@implementation IPViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

- (void)viewDidAppear:(BOOL)animated
{
    [super viewDidAppear:animated];
    
    [self performSelector:@selector(refreshIPAddress:) withObject:nil afterDelay:0.0];
}

#pragma mark - Actions
- (IBAction)refreshIPAddress:(UIButton *)sender
{
    [self.localActivityIndicator startAnimating];
    [B9ZGX_IPDetector getLANIPAddressWithCompletion:^(NSString *IPAddress) {
        self.localLabel.text = IPAddress;
        [self.localActivityIndicator stopAnimating];
    }];
    
    [self.remoteActivityIndicator startAnimating];
    [B9ZGX_IPDetector getWANIPAddressWithCompletion:^(NSString *IPAddress) {
        self.remoteLabel.text = IPAddress;
        [self.remoteActivityIndicator stopAnimating];
    }];
}


@end
